package com.imooc.town.reponsitory;

import com.imooc.town.dataobject.ProductCategory;
import org.springframework.data.jpa.repository.JpaRepository;

import java.sql.*;
import java.util.List;

/**
 * Created by 10077 on 2018/3/20.
 * desc:
 */
public interface ProductCategoryReponsitory extends JpaRepository<ProductCategory,Integer> {


    public List<ProductCategory> findByCategoryTypeIn(List<Integer> categoryTypeList);




    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String driver = "com.mysql.jdbc.Driver";
        String url = "jdbc:mysql://127.0.0.1:3306/sell";
        String user ="song";
        String password ="123123";

        try{
            Class.forName(driver);
            Connection conn= DriverManager.getConnection(url,user,password);
            if(!conn.isClosed()) {
                System.out.println("Succeed!");
            }
            Statement statement = conn.createStatement();
            String sql = "SELECT * FROM product_category";
            ResultSet rs = statement.executeQuery(sql);
            String name = null;
            while(rs.next()){
                //name = rs.getString("name");
                System.out.println("id:"+rs.getString("category_id")+"  "+"name:"+rs.getString("category_name"));
            }
            rs.close();
            conn.close();
        }catch(ClassNotFoundException e){
            System.out.println("sorry,can't find the driver");
            e.printStackTrace();
        }catch(SQLException e){
            e.printStackTrace();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
